package com.bb.flow.service.imp.node.UserLoginFlow;

import com.bb.flow.api.ConditionValueCalc;
import com.bb.flow.api.ExpressionCalc;
import com.bb.flow.api.entries.ConditionResult;
import com.bb.flow.api.entries.FlowContext;
import com.bb.flow.config.enumtype.DataType;

public class CalcFlowStartConditon implements ConditionValueCalc, ExpressionCalc {

    private static final String USER_COUNT = "UserCount";

    /**
     * 结果条件条件判断
     *
     * @param flowNodeData  流程上下文参数
     * @return true:传入的条件成功,false:条件不成立
     */
    @Override
    public ConditionResult calcExpress(FlowContext flowNodeData) {

        ConditionResult conditionResult = new ConditionResult();
        conditionResult.setDataType(DataType.BOOLEAN);
        conditionResult.setResult(false);
        return conditionResult;
    }

    /**
     * 计算表达式
     *
     * @param expression              表达式
     * @param flowNodeData            当前流程上下文信息
     * @param conditionNodeValueInfos 条件值结果
     * @return true 满足条件,false 不满足条件
     */
    @Override
    public boolean calc(
            String expression, FlowContext flowNodeData,
            ConditionResult result) {

            if (null == result.getResult()) {
                return true;
            }
            String s = result.getResult().toString();
            return expression != null && expression.equals(s);

    }
}
